package yqt.com.cnki.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import org.springframework.stereotype.Repository;
import yqt.com.cnki.bo.KYDABo;
import yqt.com.cnki.bo.QKKMBo;
import yqt.com.cnki.dao.IWWSJDao;
import yqt.com.cnki.po.*;

import java.util.List;

/**
 * Description:
 *
 * @author BaiGe
 * @date: 2021/11/15 14:04
 * @Version 1.0
 */
@Repository
public class WWSJDaoImpl implements IWWSJDao {
    @Override
    public List<WWSJPo> getWWSJ_LimitSix() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getWWSJ_LimitSix";
        return sqlSession.selectList(statementId, null, false);
    }

    public List<QKKMPo> getQKKM() {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getQKKM";
        return sqlSession.selectList(statementId, null, false);
    }


    public List<WWSJPo> complexSearchWWSJ_List(KYDABo qkydBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.complexSearchWWSJ_List";
        return sqlSession.selectList(statementId, qkydBo, true);
    }

    //期刊刊名检索
    public List<QKKMPo> getQKKMpageList(QKKMBo qkkmBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getQKKMpageList";
        return sqlSession.selectList(statementId, qkkmBo, true);
    }



    public long getQKKMpageList_Count(QKKMBo qkkmBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getQKKMpageList_count";
        return sqlSession.getCount(statementId, qkkmBo);
    }


    @Override
    public List<KeyValuePo> getYearForeign(String km) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getYearForeign";
        return sqlSession.selectList(statementId, km,false);
    }

    public long complexSearchWWSJ_Count(KYDABo qkydBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.complexSearchWWSJ_Count";
        return sqlSession.getCount(statementId, qkydBo);
    }


    public FZFile  getFZFile(String drid){
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getfzfile";
        return  sqlSession.selectOne(statementId,drid,false);
    }

    @Override
    public FZWUFILE getFZWUFILE(String fileId) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getFZWUFILE";
        return  sqlSession.selectOne(statementId,fileId,false);
    }

    @Override
    public String getMetaIdByDrid(String drid) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.IWWSJDao.getMetaIdByDrid";
        return  sqlSession.selectOne(statementId,drid,false);
    }
}
